{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1460
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	i,n,k,kk:longint;
	a:array[0..100010] of longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=1 to n do
	read(a[i]);
read(k);
if k<0 then begin
	k:=abs(k);
	k:=k mod n;
	k:=n-k;
end else k:=k mod n;
kk:=n-k+1;
for i:=kk to n do
	write(a[i],' ');
dec(kk);
for i:=1 to kk do
	write(a[i],' ');
end.